﻿

using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using Rio.Framework.Localisation;
using Telerik.Windows.Controls;

namespace Rio.Framework.Pages.Workflow
{
    public partial class CommentWindow : RadWindow, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Gets or sets the comment.
        /// </summary>
        /// <value>The comment.</value>
        public string Comment
        {
            get
            {
                return (string)this.GetValue(CommentProperty);
            }
            set
            {
                this.SetValue(CommentProperty, value);
            }
        }
        public static readonly DependencyProperty CommentProperty =
        DependencyProperty.Register("Comment", typeof(string), typeof(CommentWindow), null);

        /// <summary>
        /// Initializes a new instance of the <see cref="CommentWindow" /> class.
        /// </summary>
        public CommentWindow()
        {
            this.InitializeComponent();

            InitLabels();

            this.KeyDown += new KeyEventHandler(CommentWindow_KeyDown);

            this.CanMove = false;
            this.ResizeMode = Telerik.Windows.Controls.ResizeMode.NoResize;
            this.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
        }

        /// <summary>
        /// Inits the labels.
        /// </summary>
        private void InitLabels()
        {
            this.OkBtn.Content = Resx.GetLabel(ResxCommon.OK);
            this.CancelBtn.Content = Resx.GetLabel(ResxCommon.CANCEL);
            this.Header = Resx.GetLabel(ResxFlowPage.MEMO);
            LabelControl.Text = Resx.GetLabel(ResxFlowPage.MEMO);
        }

        /// <summary>
        /// Handles the KeyDown event of the CommentWindow control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.KeyEventArgs" /> instance containing the event data.</param>
        private void CommentWindow_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.Escape:
                    this.DialogResult = false;
                    this.Close();
                    break;
            }
        }

        /// <summary>
        /// Handles the Click event of the OKButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }

        /// <summary>
        /// Handles the Click event of the CancelBtn control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        private void CancelBtn_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
    }
}